function NiceScroll(targetId)
{
	this.taId = targetId;
	this.ta = id(this.taId);
	if (this.ta.nodeType != 1)
	{
		return null;
	}
	this.st = el("label");		// scroll tip
	this.sb = el("div");		// scroll bar
	this.sbH = 0;
	this.scH = 0;
	this.stH = 0;
	this.avg = 0;
	this.sbcH = 0;
	this.n = 20;
	this.enabled = true;
	this.mousePos = null;
	this.isScroll = false;
	this.onSb = false;
	this.show = false;
	this.checkTt = null;

	/* 滚动条动画效果相关 */
	this.wtId = null;			//动画timer的ids
	this.wtCounter = 0;			//timer循环次数
	this.wSpeed = 0;			//timer执行一次滚动条移动的距离
	this.woSpeed = 0;			//用于检测是否反向滚动
	/* endof 滚动条动画效果相关 */

	/* scrollBar的相关样式 */
	this.sbStyle = {
		"position":"absolute",
		"zIndex":1001,
		"width":"0.583em"
	};

	/* scrollTip的相关样式 */
	this.stStyle = {
		"width":"0.583em",
		"display":"inline-block",
		"background":"#9FE3D1",
		"borderRadius":"3px",
		"position":"relative",
		"cursor":"pointer"
	};

	/* scrollTip的opacity */
	this.stOpacity = 0.1;

	if (typeof this.init != "function")
	{
		NiceScroll.prototype.init = function(){
			var obj = this;
			this.sb.id = this.taId + "niceScrollSb" + new Date().getTime();

			setStyle(this.sb, {"backgroundColor":(this.sbStyle.background || "transparent")});

			/* 将scrollTip添加到scrollBar中 */
			this.sb.appendChild(this.st);

			/* 将scrollBar添加到body中 */
			document.body.appendChild(this.sb);

			/* 设置scrollBar和scrollTip的静态样式 */
			setStyle(this.sb, this.sbStyle);
			setStyle(this.st, this.stStyle);

			/* 设置scrollBar和scrollTip的动态样式 */
			this._reset();

			/* 设置target的overflow为hidden */
			setStyle(this.ta, {"overflow":"hidden"});

			this._shSb();
			this._bind();
			window.setTimeout(function(){
				obj.checkTt = window.setTimeout(arguments.callee, 10);
				obj._check();
			}, 100);
		};

		/* 设置scrollBar的样式 */
		NiceScroll.prototype.scrollBarSet = function(styles){
			if (typeof styles == "object")
			{
				for(var propy in styles)
				{
					this.sbStyle[propy] = styles[propy];
				}
			}
		};

		/* 设置scrollTip的样式 */
		NiceScroll.prototype.scrollTipSet = function(styles){
			if (typeof styles == "object")
			{
				for(var propy in styles)
				{
					this.stStyle[propy] = styles[propy];
				}
			}
		};

		/* 设置scrollTip的opacity */
		NiceScroll.prototype.scrollTipOpacity = function(opacity){
			this.stOpacity = opacity;
		};

		/* 滚动到指定的位置 */
		NiceScroll.prototype.scrollTo = function(hPos){
			var scollTop = parseInt(hPos);

			if (true == isNaN(scollTop))
			{
				return false;
			}

			/* 设置scrollTip初始样式 */
			this.ta.scrollTop = scollTop;
		};

		/* 动态设置scrollBar和scrollTip的样式，主要是位置 */
		NiceScroll.prototype._reset = function(){
			var pos = $(this.ta).offset();
			var width = this.ta.offsetWidth;
			var height = this.ta.offsetHeight;
			var sHeight = this.ta.scrollHeight;
			var bdTWidth = parseFloat(getNodeDefaultView(this.ta, "borderTopWidth")) || 0;
			var bdBWidth = parseFloat(getNodeDefaultView(this.ta, "borderBottomWidth")) || 0;
			var bdRWidth = parseFloat(getNodeDefaultView(this.ta, "borderRightWidth")) || 0;
			var bdLWidth = parseFloat(getNodeDefaultView(this.ta, "borderLeftWidth")) || 0;

			this.scH = sHeight - height + bdTWidth + bdBWidth;
			this.stH = parseInt(height/sHeight*height*0.7);
			this.sbcH = height - (this.stH + 2);
			this.avg = this.scH/this.sbcH;

			if (sHeight - height <= 0)
			{
				setStyle(this.sb, {"visibility":"hidden"});
				this.show = false;
				return;
			}
			else
			{
				this.show = true;
				setStyle(this.sb, {"visibility":"visible"});
			}

			/* 设置scrollBar初始样式 */
			setStyle(this.sb, {"top":pos.top + bdTWidth + "px",
							   "height":height + "px",
							   "left":pos.left + width - bdRWidth - parseInt(this.sb.offsetWidth) + "px"});

			/* 设置scrollTip初始样式 */
			setStyle(this.st, {"top":(this.ta.scrollTop/this.scH)*this.sbcH + "px",
							   "height":this.stH + "px"});

			if (this.isScroll == false)
			{
				$("#"+this.sb.id).fadeTo(1000, this.stOpacity);
			}
		};

		NiceScroll.prototype._bind = function(){
			var obj = this;
			if (document.attachEvent)
			{
				this.ta.attachEvent("onmousewheel",  function(event){
					event = event || window.event;obj._scroll(event)});
				this.sb.attachEvent("onmousewheel",  function(event){
					event = event || window.event;obj._scroll(event)});
			}
			else
			{
				this.ta.addEventListener("mousewheel",
					function(event){event = event || window.event;obj._scroll(event)}, false);
				this.ta.addEventListener("DOMMouseScroll",
					function(event){event = event || window.event;obj._scroll(event)}, false);
				this.sb.addEventListener("mousewheel",
					function(event){event = event || window.event;obj._scroll(event)}, false);
				this.sb.addEventListener("DOMMouseScroll",
					function(event){event = event || window.event;obj._scroll(event)}, false);
			}

			/* 触屏移动的处理函数 */
			function touchMoveHd(event)
			{
				event = event || window.event;
				var mousePos = {x:event.touches[0].clientX, y:event.touches[0].clientY};
				var len = mousePos.y - obj.mousePos.y;
				var top = parseFloat(obj.st.style.top) - len;

				top = (top >= obj.sbcH?obj.sbcH:(top <= 0?0:top));
				obj.st.style.top = top + "px";
				obj.mousePos.y = mousePos.y;
				obj.ta.scrollTop = obj.scH*(top/obj.sbcH);
				obj.isScroll = true;
				eventPreventDefault(event);
				clearSelection(event);
			};

			/* 触屏结束移动的处理函数 */
			function touchEndHd(event)
			{
				detachEvnt(document, "touchmove", touchMoveHd);
				detachEvnt(document, "touchend", touchEndHd);

				if (obj.onSb == false)
				{
					obj.isScroll = false;
				}
			};

			/* 触屏移动开始的处理函数 */
			attachEvnt(this.ta, "touchstart", function(event){
				event = event || window.event;
				obj.mousePos = {x:event.touches[0].clientX, y:event.touches[0].clientY};
				attachEvnt(document, "touchmove", touchMoveHd);
				attachEvnt(document, "touchend", touchEndHd);
			});

			/* 对滑动块绑定鼠标函数 */
			this.st.onmousedown = function(event){
				obj.mousePos = getMousePos(event);
				document.onmouseup = function(event){
					document.onmousemove = null;
					document.onmouseup = null;
					if (obj.onSb == false)
					{
						obj.isScroll = false;
					}
				};
				document.onmousemove = function(event){
					var mousePos = getMousePos(event);
					var len = mousePos.y - obj.mousePos.y;
					var top = parseFloat(obj.st.style.top) + len;
					
					top = (top >= obj.sbcH?obj.sbcH:(top <= 0?0:top));
					obj.st.style.top = top + "px";
					obj.mousePos.y = mousePos.y;
					obj.ta.scrollTop = obj.scH*(top/obj.sbcH);
					obj.isScroll = true;
					clearSelection(event);
				};
			};

			/* 在scrollBar上绑定鼠标事件 */
			$("#"+this.sb.id)[0].onmouseover = function(event){
				event = event || window.event;
				obj.onSb = true;
				if (obj.show == true)
				{
					obj._scrollShow(event);
				}
			};
			$("#"+this.sb.id)[0].onmouseout = function(){
				obj.onSb = false;
				obj.isScroll = false;
			};
		};

		NiceScroll.prototype._close = function(){
			this.sb.style.visibility = "hidden";
			this.enabled = false;
		};

		NiceScroll.prototype._open = function(){
			this.enabled = true;
		};

		NiceScroll.prototype._shSb = function(){
			if (this.ta.style.display == "none" ||
				this.ta.visibility == "hidden")
			{
				this.sb.style.visibility = "hidden";
			}
			else
			{
				this.sb.style.visibility = "visible";
			}
		};

		NiceScroll.prototype._check = function(){
			if (id(this.taId) == null)
			{
				window.clearTimeout(this.checkTt);
				this.sb.parentNode.removeChild(this.sb);
				return;
			}
			if (this.enabled == false)
			{
				return;
			}

			if (checkInHorize(this.ta) == false)
			{
				this.sb.style.display = "none";
				return;
			}
			else
			{
				this.sb.style.display = "block";
			}
			
			if (parseInt(this.ta.offsetHeight) <= 0)
			{
				this.sb.style.visibility = "hidden";
			}
			this._reset();
		};

		NiceScroll.prototype._getWheelDelta = function(event){
			event = event || window.event;
			if (event.wheelDelta)
			{
				return window.opera&&window.opera.version < 9.5?-event.wheelDelta:event.wheelDelta;
			}
			else
			{
				return -event.detail*40;
			}
		};

		NiceScroll.prototype._wheelAnimate = function(speed, counter){
			var obj = this, oppsite = false;
			if (this.wtId)	/* 连续触发 */
			{
				oppsite = (this.woSpeed ^ speed) < 0;
				this.wtCounter = oppsite ? counter : (this.wtCounter + counter < 50 ? this.wtCounter + counter : 50);
				this.wSpeed = oppsite? speed : this.wSpeed*1.05;		/* 加速 */
				return;
			}
			this.wtCounter = counter;
			this.woSpeed = this.wSpeed = speed;
			(function()
			{
				var temp = 0;
				
				obj.wtId = window.setTimeout(arguments.callee, 5);
				if (obj.wtCounter < 0)
				{
					clearTimeout(obj.wtId);
					obj.wtId = null;
					if (obj.onSb == false)
					{
						obj.isScroll = false;
					}
					return;
				}
				var newTop = parseFloat(obj.ta.scrollTop) + parseInt(obj.wSpeed);
				if (newTop >= obj.scH || newTop <= 0)
				{
					obj.wtCounter = 0;
				}
				obj.ta.scrollTop = newTop;
				temp = (obj.ta.scrollTop/obj.scH)*obj.sbcH;
				if (!isNaN(temp))
				{
					obj.st.style.top = temp + "px";	/* 同步滚动条 */
				}
				obj.wtCounter--;
			})();
		};

		NiceScroll.prototype._scrollShow = function(event){
			$("#"+this.sb.id).stop(true).css("visibility", "visible").css("opacity", 1);
			this.isScroll = true;
			eventPreventDefault(event);
		};

		NiceScroll.prototype._scroll = function(event){
			event = event || window.event;
			var delta = this._getWheelDelta(event);
			var st = this.ta.scrollTop;
			var result = delta > 0?-1:1;
			if (this.show == true && this.enabled == true)
			{
				this._scrollShow(event);
				this._wheelAnimate(5 * result, 7);
			}
		};
	}
}
function DateControl(dateConId, options)
{
	this.table;
	this.weekList;
	this.hourList;
	this.dateCon = id(dateConId);
	this.weekIsMouseDown = false;
	this.selDate = [0, 0, 0, 0, 0, 0, 0];
	this.dateArray = [0, 0, 0, 0, 0, 0, 0];
	this.cellHeight = 22;
	this.cellWidth = 22;
	this.cellSeColor = "#A0D468";
	this.cellDeColor = "#FCFCFC";
	this.cellPadding = 1;

	if (DateControl.prototype.init == undefined)
	{
		DateControl.prototype.hourStr = label.lHour;
		DateControl.prototype.weekDayNum = 7;
		DateControl.prototype.lineStr = "-";
		DateControl.prototype.selTag = "selTag";
		DateControl.prototype.cellBorderWidth = 1;
		DateControl.prototype.iCellIndex = 0;
		DateControl.prototype.weekArray = [label.Mon, label.Tue, label.Wen, 
										   label.Thu, label.Fri, label.Sta, label.Sun];

		/* Date的初始化 */
		DateControl.prototype._init = function()
		{
			this._initOptions();
			this._dateConInit();
			this._hourListInit();
			this._weekListInit();
			this._dateTableInit();
		};

		/* 重新设置显示的时间 */
		DateControl.prototype.reset = function(dateArray)
		{
			var dayMask, tr, td, iCell, iCellIndex = this.iCellIndex;
			var objThis = this;

			if (dateArray instanceof Array == false ||
				dateArray == undefined || 
				dateArray.length != this.weekDayNum)
			{
				return;
			}

			for(var j = 0; j < this.weekDayNum; j++)
			{
				tr = this.table.rows[j];
				dayMask = dateArray[j];

				for (var i = 0; i < 24; i++)
				{
					td = tr.cells[i];
					iCell = td.childNodes[iCellIndex];

					if (dayMask != undefined)
					{
						this._setSel(iCell, dayMask%2);
						dayMask = (dayMask >> 1);
					}
					else
					{
						this._setSel(iCell, 0);
					}
				}
			}
		};

		/* 初始化options */
		DateControl.prototype._initOptions = function()
		{
			for (var propty in options)
			{
				if (typeof this[propty] != "undefined")
				{
					this[propty] = options[propty];
				}
			}
		};

		/* 获取已选择的时间 */
		DateControl.prototype.getSelDate = function()
		{
			var cell, selectNum, row, iCell;
			var weekDayNum = this.weekDayNum;
			var rows = this.table.rows;
			this.selDate = [0, 0, 0, 0, 0, 0, 0];

			for(var j = 0; j < weekDayNum; j++)
			{
				row = rows[j];

				for (var i = 0; i < 24; i++)
				{
					cell = row.cells[i];
					iCell = cell.childNodes[0];
					selectNum = parseInt(iCell.getAttribute("sel"));

					if (selectNum == 1)
					{
						this.selDate[j] += Math.pow(2, i);
					}
				}
			}

			return this.selDate;
		};

		DateControl.prototype._dateConInit = function()
		{
			this.dateCon.style.overflow = "hidden";
		};

		/* 时刻列表初始化 */
		DateControl.prototype._hourListInit = function()
		{
			var hourList = document.createElement("ul");
			var li, text, iCell, thisObj = this, span;

			hourList.className = "hourList";

			for(var i = 0; i <= 24; i++)
			{
				li = document.createElement("li");
				if (i != 24)
				{
					iCell = document.createElement("span");
					iCell.innerHTML = i;
					li.appendChild(iCell);
					li.style.width = this.cellWidth + this.cellPadding*2 + this.cellBorderWidth + "px";
					iCell.onclick = (function(index){
						return function(){
							var rows = thisObj.table.rows;
							var len = rows.length;
							var iCellIndex = thisObj.iCellIndex;
							var selMask = 1;

							for (var j = 0; j < len; j++)
							{
								selMask = selMask&parseInt(rows[j].cells[index].childNodes[iCellIndex].getAttribute("sel"));
								if (0 == selMask)
								{
									break;
								}
							}

							selMask = 1 - selMask;

							for (var j = 0; j < len; j++)
							{
								thisObj._setSel(rows[j].cells[index].childNodes[iCellIndex], selMask);
							}

							clearSelection();
						};
					})(i);
				}
				else
				{
					li.style.color = "#6EBFD9";
					li.innerHTML = this.hourStr;
				}

				hourList.appendChild(li);
			}

			this.dateCon.appendChild(hourList);
			this.hourList = hourList;
		};

		/* 星期列表初始化 */
		DateControl.prototype._weekListInit = function()
		{
			var weekList = document.createElement("ul");
			var li, thisObj = this;

			weekList.className = "weekList";

			for(var i = 0, len = this.weekDayNum; i < len; i++)
			{
				li = document.createElement("li");
				li.style.height = this.cellHeight + this.cellPadding*2 + this.cellBorderWidth + "px";
				li.style.lineHeight = this.cellHeight + this.cellPadding*2 + this.cellBorderWidth + "px";
				li.innerHTML = this.weekArray[i];
				li.onclick = (function(index){
					return function(){
						var cells = thisObj.table.rows[index].cells;
						var iCellIndex = thisObj.iCellIndex;
						var selMask = 1;

						for (var j = 0, len = cells.length; j < len; j++)
						{
							selMask = selMask&parseInt(cells[j].childNodes[iCellIndex].getAttribute("sel"));
							if (0 == selMask)
							{
								break;
							}
						}

						selMask = 1 - selMask;

						for (var j = 0, len = cells.length; j < len; j++)
						{
							thisObj._setSel(cells[j].childNodes[iCellIndex], selMask);
						}

						clearSelection();
					};
				})(i);
				weekList.appendChild(li);
			}

			this.dateCon.appendChild(weekList);
			this.weekList = weekList;
		};

		/* 设置时间块是否被选择 */
		DateControl.prototype._setSel = function(obj, num){
			obj.setAttribute("sel", num);
			obj.style.backgroundColor = (num == 1 ? this.cellSeColor : this.cellDeColor);
		};

		/* 生成时间cell */
		DateControl.prototype._dateCellCreate = function()
		{
			var dayMask, tr, td, iCell, index;
			var objThis = this;

			for (var j = 0, len = this.weekDayNum; j < len; j++)
			{
				tr = this.table.insertRow(-1);

				if (this.dateArray != undefined)
				{
					dayMask = this.dateArray[j];
				}

				for (var i = 0; i < 24; i++)
				{
					td = tr.insertCell(-1);
					td.style.padding = this.cellPadding + "px";
					td.className = "weekTd";

					iCell = document.createElement("i");
					iCell.className = "tableICell";
					iCell.style.height = this.cellHeight + "px";
					iCell.style.width = this.cellWidth + "px";
					td.appendChild(iCell);

					this._setSel(iCell, 0);

					if (dayMask != undefined)
					{
						this._setSel(iCell, dayMask%2);
						dayMask = (dayMask >> 1);
					}
					else
					{
						this._setSel(iCell, 0);
					}

					iCell.onmouseover = function (event){
						if (objThis.weekIsMouseDown == true)
						{
							objThis._setSel(this, 1 - parseInt(this.getAttribute("sel")));
						}
					};

					iCell.onmousedown = function (event){
						objThis._setSel(this, 1 - parseInt(this.getAttribute("sel")));
					};
				}
			}

			if (this.table.rows[0].cells[0].nodeType == 3)
			{
				this.iCellIndex = 1;
			}
		};

		/* 添加处理函数 */
		DateControl.prototype._dateCellBind = function()
		{
			var objThis = this;
			this.table.onmousedown = function (event){
				objThis.weekIsMouseDown = true;
				document.onmouseup = function (event){
					objThis.weekIsMouseDown = false;
				}
			};

			this.table.onmouseup = function (event){
				objThis.weekIsMouseDown = false;
			};
		};

		/* 生成时间表 */
		DateControl.prototype._dateTableCreate = function()
		{
			this.table = document.createElement("table");
			this.table.className = "tableWeek";
			this.table.cellspacing = "0px";
			this.table.cellpadding = "0px";
			this.dateCon.appendChild(this.table);
		};

		/* 初始化具体的时间表格 */
		DateControl.prototype._dateTableInit = function()
		{
			this._dateTableCreate();
			this._dateCellCreate();
			this._dateCellBind();
		};
	}

	this._init();
}
function PageFunc()
{
	this.pathStr = "../";
	this.htmlPathStr = this.pathStr + "common/";
	this.loginId = "Login";
	this.loadPageData = {url:"", id:""};
	this.isPostfunc;
	this.helpIdStr = "helpStr";
	this.LGKEYSTR = "lgKey";
	this.LGKEYTIMESTR = "lgKeyTime";
	
	this.$Init = function()
	{
		Quary.call(jQuery);
		$.setDataParseFunc($.parser);
		$.getExplorer();
		$.initUrl();
	}

	this.logout = function()
	{
		$.logout();
		loadPage("Content.htm", "Con");
		id("Con").innerHTML = "";
	};

	this.loadPageHandleBg = function()
	{
		var helpBtns = $("i.helpBtn");
		var idStr, helpBtn;

		/* bind input hover */
		initHoverBd();

		/* bind help */
		for (var i = 0, len = helpBtns.length; i < len; i++)
		{
			helpBtn = helpBtns[i];
			idStr = "";
			idStr = helpBtn.getAttribute(helpIdStr);

			if (idStr != null)
			{
				helpBind(helpBtns[i], idStr);
			}
		}
	};

	/* load page to the target container */
	this.loadPage = function(url, id, callBack)
	{
		var obj = this;

		/* for the bug of IE6.0 ~ IE8.0 */
		window.setTimeout(function(){
			helpClose();
			closeAlert();
			closeConfirm();

			$.load(obj.htmlPathStr + url, callBack, id);
			closeProgBar();
		}, 0);
	};

	/* check for dns redirect */
	this.pageRedirect = function()
	{
		var url = window.top.location.href;
		var domain = "tplogin.cn";

		/* 处理DNS重定向 */
		if (USER_GROUP_REMOTE != $.group && 
			false == /^((http:\/\/)*(\d{1,3}\.){3}\d{1,3})/g.test(url) &&
			url.indexOf(domain) < 0 && false == $.local)
		{
			window.top.location.href = $.httpTag + domain;
		}
	};

	this.pageOnload = function()
	{
		var links = [{tag:"link", url:"../dynaform/menu.css"},
					 {tag:"link", url:"../dynaform/DataGrid.css"}];

		var scripts = [{tag:"script", url:"../lib/verify.js"},
					   {tag:"script", url:"../dynaform/macFactory.js"},
					   {tag:"script", url:"../dynaform/DataGrid.js"},
					   {tag:"script", url:"../dynaform/menu.js"}];

		var delayscripts = [{tag:"script", url:"../lib/jquery-1.10.1.min.js"},
							{tag:"script", url:"../lib/model.js"},
							{tag:"script", url:"../lib/DM.js"},
							{tag:"script", url:"../language/cn/str.js"},
							{tag:"script", url:"../language/cn/error.js"},
							{tag:"script", url:"../lib/Quary.js"},
							{tag:"script", url:"../lib/ajax.js"}];

		this.loadExternResource({scripts:delayscripts, callBack:function()
		{
			$Init();

			/* 注册相应处理函数 */
			$.setexternJSP(replaceJSP);
			$.setExternPageHandle(loadPageHandleBg);
			$.setLoginErrHandle(showLogin);
			$.setPRHandle(pageRedirect);

			window.authInfo = [];
			this.loadExternResource({scripts:scripts, links:links});
			this.compatibleShow();
			this.localSgInit();
			this.loadPage("Content.htm", "Con");
		}});

		document.oncontextmenu = function(event){
			return false;
		};

		if (isIESix)
		{
			try{document.execCommand('BackgroundImageCache', false, true);}catch(e){};
		}
	};

	this.unloadDetail = function(canvasId)
	{
		var detail = id(canvasId);
		if (detail)
		{
			detail.innerHTML = "";
		}
	};

	this.detailShow = function(conId, callBack)
	{
		$("#"+conId).fadeIn(800, callBack);
	};

	this.detailHide = function(conId, canvasId)
	{
		$("#"+conId).fadeOut(800, function(){
			$("#"+conId).css("display", "none");
			window.unloadDetail(canvasId);
		});
	};

	this.selectChange = function(objId, obj)
	{
		id(objId).value = obj.options[obj.selectedIndex].text;
	};

	this.loginChange = function(showTag)
	{
		var loginCon = this.id(this.loginId);
		var other = "block", login = "none";
		var color = "#FFFFFF", node, nodes = document.body.childNodes;

		if (showTag == true)
		{
			other = "none";
			login = "block";
			color = "#F2F2F2";
		}

		for(var index in nodes)
		{
			node = nodes[index];
			if (node.nodeName != undefined 
				&& node.nodeName.toUpperCase() == "DIV"
				&& node.id != this.loginId)
			{
				this.setStyle(node, {"display":other});
			}
		}

		loginCon.innerHTML = "";
		this.setStyle(loginCon, {"display":login});
		this.setStyle(document.body, {"backgroundColor":color});

		if (showTag == true)
		{
			if ($.unChgPwd == authInfo[1])
			{
				id("Con").innerHTML = "";
				this.loadPage("LoginChgPwd.htm", this.loginId);
			}
			else
			{
				$.setLgPwd("");
				this.loadPage("Login.htm", this.loginId);
			}
		}
		else
		{
			if ($.unChgPwd == authInfo[1])
			{
				loadPage("Content.htm", "Con");
			}
			else
			{
				/* this.isPostfunc不为空，表明是post */
				if (this.isPostfunc)
				{
					this.isPostfunc();
				}
				else
				{
					this.loadPage(this.loadPageData.url, this.loadPageData.id);
				}
			}
		}
	};

	this.setLoadPage = function(url, idStr)
	{
		this.loadPageData.url = url;
		this.loadPageData.id = idStr;
	};

	this.localSgInit = function()
	{
		try
		{
			this.sessionLS.init();
			if (true == isIE && false == isIENormal)
			{
				(function(){
					sessionLS.setExpire(3*1000);
					window.setTimeout(arguments.callee, 1*1000);
				})();
			}
		}catch(ex){}
		this.getLgPwd();
	};

	this.auth = function()
	{
		$.auth($.pwd);
	};

	this.getLgPwd = function()
	{
		try
		{
			$.pwd = sessionLS.getItem(this.LGKEYSTR);
		}catch(ex){};
	};

	this.showLogin = function(func)
	{
		this.isPostfunc = func;
		this.loginChange(true);
	};

	this.unloadLogin = function()
	{
		this.loginChange(false);
	};

	this.iFrmOnload = function (idStr, callBack, unAuthHandle)
	{
		var data = {}, errorno = ENONE;
		var ifrm = id(idStr);
		var isNum = false;

		try
		{
			if (ifrm.contentWindow)
			{
				data.responeText = ifrm.contentWindow.document.body ? ifrm.contentWindow.document.body.innerHTML : null;
				data.responeXML = ifrm.contentWindow.document.XMLDocument ? ifrm.contentWindow.document.XMLDocument : ifrm.contentWindow.document;
			}
			else
			{
				data.responeText = ifrm.contentDocument.document.body ? ifrm.contentDocument.document.body.innerHTML : null;
				data.responeXML = ifrm.contentDocument.document.XMLDocument ? ifrm.contentDocument.document.XMLDocument : ifrm.contentDocument.document;
			}

			isNum = /([0-9]+)/g.test(data.responeText);
			errorno = (false == isNum ? EINVFMT : parseInt(RegExp["$1"]));

			/* 错误。直接退出 */
			if (errorno != ENONE)
			{
				closeProgBar();
			}

			callBack(errorno);
		}
		catch(ex)
		{
			closeProgBar();
			callBack(EINVFMT);
		}
	};

	this.windowSleep = function(milliSeconds) 
	{ 
		var now = new Date();
		var exitTime = now.getTime() + milliSeconds;  
		while (true) 
		{ 
			now = new Date();
			if (now.getTime() > exitTime)
			{
				return;
			}
		}
	};

	/* 获取本机MAC地址 */
	this.getCurrPcMac = function()
	{
		var pos, result = $.getPeerMac();

		if (ENONE != result.errorno || "" == result.data)
		{
			return "00-00-00-00-00-00";
		}

		pos = result.data.indexOf("\r\n");
		return result.data.substring(0, pos);
	};

	/* 克隆本机MAC地址 */
	this.cloneLocalMac = function(){
		var system = $.readEx(SYSTEM_DATA_ID);
		var localMac = this.getCurrPcMac();
		var errNo = ENONE;

		if (system.mac[1] != localMac)
		{
			system.mac[1] = localMac;
			errNo = $.write($.toText(system), $.block);
		}

		return errNo;
	};

	/* 获取log */
	this.logSave = function ()
	{
		var url = $.domainUrl + "syslog.txt" + "?code="+ TDDP_INSTRUCT +"&asyn=0" + "&disposition=1";

		location.href = $.orgURL(url);
		return true;
	};
	/* 异步加载资源 */
	this.loadExternResource = function(obj)
	{
		var elem, links, scripts, callBack, hasReadyState;
		var head = document.getElementsByTagName("head")[0];
		var ObjOrg = {links:null, scripts:null, callBack:null};

		/* 初始化参数列表 */
		for(var prop in obj)
		{
			ObjOrg[prop] = obj[prop];
		}

		links = ObjOrg.links;
		scripts = ObjOrg.scripts;
		callBack = ObjOrg.callBack;

		/* 加载CSS */
		if (links != undefined)
		{
			for (var i in links)
			{
				elem = document.createElement("link");
				elem.rel = "stylesheet";
				elem.href = links[i].url;
				head.appendChild(elem);
			}
		}

		/* 加载js */
		if (scripts != undefined)
		{
			var load, loadHandle, loadCallBack;

			elem = document.createElement("script");
			elem.type = "text/javascript";

			if (callBack != undefined)
			{
				hasReadyState = (elem.readyState != undefined);
				loadCallBack = function(index)
				{
					scripts[index].loadState = true;

					for (var j in scripts)
					{
						if (false == scripts[j].loadState)
						{
							return;
						}
					}

					callBack();
				};

				for (var i in scripts)
				{
					scripts[i].loadState = false;
				}
			}

			for (var i in scripts)
			{
				elem = document.createElement("script");
				elem.type = "text/javascript";

					if (callBack != undefined)
					{
						if (hasReadyState)
						{
							elem.onreadystatechange = (function(index){
								return function(){
									if (this.readyState == "loaded" || this.readyState == "complete")
									{
										this.onreadystatechange = null;
										loadCallBack(index);
									}
								};
							})(i);
						}
						else
						{
							elem.onload = (function(index){
								return function(){
									loadCallBack(index);
								};
							})(i);
						}
					}

				elem.src = scripts[i].url;
				head.appendChild(elem);
			}
		}
	};
}
function Cover()
{
	Style.call(this);
	this.CoverId = "Cover";

	this.hideCover = function(callBack, externStyles)
	{
		var cover = id(this.CoverId);

		this.setStyle(cover, {"display":"none", "visibility":"hidden"});
		this.setStyle(cover, externStyles);

		if (typeof callBack != "undefined")
		{
			callBack(cover);
		}

		cover.innerHTML = "";
	};

	this.showCover = function(callBack, externStyles)
	{
		var cover = id(this.CoverId);

		this.setStyle(cover, {"display":"block", "visibility":"visible"});
		this.setStyle(cover, externStyles);

		if (typeof callBack != "undefined")
		{
			callBack(cover);
		}
	};
}
function Style()
{
	this.disableCol = "#b2b2b2";

	/* set the element styles with the styles */
	this.setStyle = function (ele, styles)
	{
		if (ele == null || styles == null || ele.nodeType != 1)
		{
			return;
		}
		
		for (var property in styles)
		{
			try
			{
				ele.style[property] = styles[property];
			}catch(ex){}
		}
	};
	
	/* get the default style of the element*/
	this.getNodeDefaultView = function(element, cssProperty)
	{
		var dv = null;
		if (!(element))
		{
			return null;
		}

		try{
			if (element.currentStyle)
			{
				dv = element.currentStyle;
			}
			else
			{
				dv = document.defaultView.getComputedStyle(element, null);
			}

			if (cssProperty != undefined)
			{
				return dv[cssProperty];
			}
			else
			{
				return dv;
			}
		}catch(ex){}
	};
}
function LocalStorageSD()
{
	try
	{
		if (null == this.sessionStorage)
		{
			this.sessionLS = {
				file_name:"user_data_default_SD",
				dom:null,
				init:function()
				{
					var dom = document.createElement('input');

					dom.type = "hidden";
					dom.addBehavior("#default#userData");
					document.body.appendChild(dom);
					dom.save(this.file_name);
					this.dom = dom;
				},
				setItem:function(k, v)
				{
					this.dom.setAttribute(k,v);
					this.dom.save(this.file_name);
				}, 
				getItem:function(k, file_name)
				{
					this.dom.load(this.file_name); 
					return this.dom.getAttribute(k); 
				}, 
				removeItem:function(k)
				{
					this.dom.removeAttribute(k);
					this.dom.save(this.file_name);
				},
				setExpire:function(timeSecond)
				{
				   var now = new Date();

				   now = new Date(now.getTime() + timeSecond);
				   this.dom.load(this.file_name);
				   this.dom.expires = now.toUTCString();
				   this.dom.save(this.file_name);
				}
			};
		}
		else
		{
			this.sessionLS = sessionStorage;
		}
	}catch(ex){};
}
function Explorer()
{
	this.isIE = false;
	this.isIESix = false;
	this.isIESeven = false;
	this.isIENormal = false;
	this.explorerInfo = navigator.userAgent;
	
	this.getIEInfo = function ()
	{
		isIE = /msie ((\d+\.)+\d+)/i.test(explorerInfo)?(document.mode || RegExp["$1"]):false;
		if (isIE != false)
		{
			if (isIE <= 6)
			{
				this.isIESix = true;
			}
			else if (isIE == 7)
			{
				this.isIESeven = true;
			}
			else if (isIE >= 9)
			{
				this.isIENormal = true;
			}

			this.isIE = true;
		}
	};

	this.compatibleShow = function(){
		if (true == this.isIESix)
		{
			var posDiv, conDiv, i, span, spanClose;
			var closeKey = "ieSixClosed";

			if (document.cookie.indexOf(closeKey) >= 0)
			{
				return;
			}

			posDiv = $("div.ieSixCompatible");
			if (undefined == posDiv[0])
			{
				posDiv = el("div");
				posDiv.className = "ieSixCompatible";

				conDiv = el("div");
				conDiv.className = "ieSixCpCon";

				i = el("i");

				span = el("span");
				span.className = "spanNote";
				span.innerHTML = label.IESixCpTip;

				spanClose = el("span");
				spanClose.className = "spanClose";
				spanClose.innerHTML = label.iknown;
				spanClose.onclick = function(){
					document.cookie = closeKey + "=true";
					posDiv.style.visibility = "hidden";
					posDiv.style.top = "-9999px";
				};

				conDiv.appendChild(i);
				conDiv.appendChild(span);
				conDiv.appendChild(spanClose);
				posDiv.appendChild(conDiv);
				document.body.appendChild(posDiv);
			}
		}
	};

	this.createGroupRadio = function(name){
		var raidoEl;

		if (undefined == name)
		{
			return raidoEl;
		}

		if (this.isIE == true && this.isIENormal == false)
		{
			raidoEl = document.createElement("<input name='"+ name +"' />");
		}
		else
		{
			raidoEl = document.createElement("input");
			raidoEl.name = name;
		}

		return raidoEl;
	};

	this.getIEInfo();	
}
function Tool()
{
	Style.call(this);
	
	/* get element by id */
	this.id = function(idStr)
	{
		if (idStr != undefined)
		{
			return document.getElementById(idStr);
		}
	};
	
	/* create element */
	this.el = function(str)
	{
		try
		{
			return document.createElement(str);
		}catch(ex){return null;}
	};
	
	/* replace <%....%> to realize multi languages */
	this.replaceJSP = function(str)
	{
		var matches = null, strRepace;
		var tagL = "<%", tagR = "%>";
		var rp = /<%(\w+)\.(\w+)%>/i;
		
		matches = rp.exec(str);
		try
		{
			while(matches != null)
			{				
				strRepace = language[matches[1]][matches[2]];
				str = str.replace(tagL + matches[1] + "." + matches[2] + tagR, strRepace);
				matches = rp.exec(str);
			}
		}catch(ex){}
		return str;
	};
	
	/* get the offsetLeft and offsetTop to the border of the explorer */
	this.getoffset = function(obj)
	{
		var tempObj = obj;
		var relPo = {
			top:0,
			left:0
		};
		
		while(true)
		{
			relPo.left += parseInt(tempObj.offsetLeft);
			relPo.top += parseInt(tempObj.offsetTop);
			tempObj = tempObj.offsetParent;
			if (tempObj == null)
			{
				break;
			}
		}
		return relPo;
	};
	
	this.attachEvnt = function(target, event, handle)
	{
		if (event.indexOf("on") == 0)
		{
			event = event.substring(2);
		}

		if (document.body.attachEvent)
		{
			target.attachEvent("on"+event, handle);
		}
		else
		{
			target.addEventListener(event, handle, false);
		}
	};

	this.detachEvnt = function(target, event, handle){
		if (event.indexOf("on") == 0)
		{
			event = event.substring(2);
		}

		if (document.body.attachEvent)
		{
			target.detachEvent("on" + event, handle);
		}
		else
		{
			target.removeEventListener(event, handle, false);
		}
	};

	/* stop propagation of event */
	this.stopProp = function (event)
	{
		event = event || window.event;
		if (event.stopPropagation)
		{
			event.stopPropagation();
		}
		else
		{
			event.cancelBubble = true;
		}
	};
	
	/* prevent defaut operation of event */
	this.eventPreventDefault = function (event)
	{
		event = event || window.event;
		if(event.preventDefault)
		{
			event.preventDefault();
		}
		else
		{
			event.returnValue = false;
		}
	};

	/* clear selection produced width mouse move */
	this.clearSelection = function ()
	{
		window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
	};

	/* 设置dom上range的光标位置 */
	this.setDomCursorPos = function (dom, pos)
	{ 
		if (dom.setSelectionRange)
		{
			dom.focus();
			dom.setSelectionRange(pos, pos);
		}
		else if (dom.createTextRange)
		{
			var range = dom.createTextRange()
			range.collapse(true);
			range.moveEnd('character', pos);
			range.moveStart('character', pos);
			range.select();
		}
	}

	/* get the pos of the mouse width the event */
	this.getMousePos = function (event)
	{
		event = event || window.event;
		var doc = document;
		var pos = (event.pageX || event.pageY) ? {x:event.pageX,y:event.pageY}:
				{x:event.clientX + doc.documentElement.scrollLeft - doc.documentElement.clientLeft,
				 y:event.clientY + doc.documentElement.scrollTop - doc.documentElement.clientTop};
		return pos;
	};
	
	/* 判断对象是否是数组 */
	this.isArray = function (obj)
	{
		return Object.prototype.toString.call(obj) === '[object Array]';
	};
	
	/* create up down */
	this.upDown = function (con, taId, classNameUp, classNameDown, callBack)
	{
		if (classNameUp == undefined || classNameDown == undefined)
		{
			return;
		}
		
		var lbl = this.el("label");
		
		lbl.className = classNameDown;
		lbl.onclick = function(){
			$("#"+taId).slideToggle("normal", function(){
				lbl.className = (lbl.className == classNameUp?classNameDown:classNameUp);
				if (callBack)
				{
					try
					{
						callBack();
					}catch(ex){}
				}
			});
		};
		con.appendChild(lbl);
		
		return lbl;
	};
	
	this.arrowUpDown = function (con, taId, callBack){
		this.upDown(con, taId, "arrowUp", "arrowDown", callBack);
	};
	
	/* 获取dom节点下指定类型的节点，index可选, filter:"input checkbox" */
	this.getChildNode = function(parent, filter, index){
		var childs = parent.childNodes;
		var nodes = [], count = 0, tempNode;
		var paras = filter.split(" ");
		var nodeName = paras[0], type = paras[1];

		for(var i = 0, len = childs.length;i < len; i++)
		{
			tempNode = childs[i];
			if (tempNode.tagName.toLowerCase() == nodeName)
			{
				if (type != undefined && tempNode["type"] == type)
				{
					nodes[count] = tempNode;
					count++;
				}
				else if (type == undefined)
				{
					nodes[count] = tempNode;
					count++;
				}
			}
		}
		if (index != undefined)
		{
			return nodes[index];
		}

		return nodes[0];
	};

	/* 检查节点是否可见 */
	this.checkInHorize = function(ta){
		var node = ta;
		while(node != null && node.nodeName.toUpperCase() != "HTML")
		{
			if (this.getNodeDefaultView(node, "visibility") == "hidden" ||
				this.getNodeDefaultView(node, "display") == "none")
			{
				return false;
			}
			node = node.parentNode;
		}

		return true;
	};

	this.setUrlHash = function(key, value)
	{
		var strH, strT, pos, tag ="";
		var url = location.href;
		var hash = location.hash;

		if (key == undefined || 
			value == undefined ||
			key.length == 0)
		{
			return;
		}
		
		if (hash.length != 0)
		{
			pos = hash.indexOf(key);
			if (pos >= 0)
			{
				strH = hash.substring(0, pos);
				strT = hash.substring(pos);
				pos = strT.indexOf("#");
				if (pos > 0)
				{
					strT = strT.substring(pos);
					hash = strH + key + "=" + value + strT;
				}
				else
				{
					hash = strH + key + "=" + value;
				}
			}
			else
			{
				if (hash.substring(hash.length - 1) != "#")
				{
					tag = "#";
				}
				hash += (tag + key + "=" + value);
			}

			location.href = url.substring(0, url.indexOf("#")) + hash;
		}
		else
		{
			if (url.lastIndexOf("#") == (url.length - 1))
			{
				location.href += (key + "=" + value);
			}
			else
			{
				location.href += ("#" + key + "=" + value);
			}
		}
	};

	this.getUrlHash = function(key)
	{
		var hash = location.hash;
		var pos = hash.indexOf(key);
		var strArr, tempArr, value = "";

		if (pos > 0)
		{
			strArr = hash.substring(1).split("#");
			for(var index in strArr)
			{
				tempArr = strArr[index].split("=");
				if (tempArr[0] == key)
				{
					value = tempArr[1];
					break;
				}
			}
		}

		return value;
	};

	this.changeUrlHash = function(str)
	{
		var url = location.href;
		var pos = url.indexOf("#");
		
		if (str == undefined)
		{
			return;
		}

		if (pos > 0)
		{
			location.href = url.substring(0, pos + 1) + str;
		}
		else
		{
			location.href = url + "#" +str;
		}
	};

	/* 设置输入框的光标的位置 */
	this.setInputCursor = function(input){
		var len = input.value.length;

		this.setDomCursorPos(input, len);
	};

	/* 获取字符串的长度，汉字占3个字符 */
	this.getCNStrLen = function(str)
	{
		return str.replace(/[^\x00-\xFF]/g, "xxx").length;
	};

	/* 获取字符串在HTML中的长度 */
	this.getCNStrHTMLLen = function(str){
		return str.replace(/[^\x00-\xFF]/g, "xx").length;
	};

	/* 截取字符串，如果超过maxNum则以...结束 */
	this.getStrInMax = function(value, maxNum){
		var str = "", strTemp, j = 0;
		var tmpStr = value.replace(/[A-Z]/g, "xx");

		if (getCNStrHTMLLen(tmpStr) <= maxNum)
		{
			return value;
		}

		for(var count = 1; count <= maxNum; count++)
		{
			strTemp = value.charAt(j);
			if (strTemp == "")
			{
				break;
			}

			if (getCNStrHTMLLen(strTemp) == 2 || /[A-Z]/g.test(strTemp) == true)
			{
				count++;
				str += strTemp;
				beCut = true;
			}
			else
			{
				str += strTemp;
			}

			j++;
		}
		return str + "...";
	};

	this.EncodeURLIMG = document.createElement("img");

	/* 对多字节字符编码 */
	this.escapeDBC = function(s)
	{
		var img = this.EncodeURLIMG;

		if (!s) 
		{
			return "";
		}

		if (window.ActiveXObject)
		{
			/* 如果是IE, 使用vbscript */
			execScript('SetLocale "zh-cn"', 'vbscript');
			return s.replace(/[\d\D]/g, function($0) {
				window.vbsval = "";
				execScript('window.vbsval=Hex(Asc("' + $0 + '"))', "vbscript");
				return "%" + window.vbsval.slice(0,2) + "%" + window.vbsval.slice(-2);
			});
		}

		/* 其它浏览器利用浏览器对请求地址自动编码的特性 */
		img.src = "nothing.png?separator=" + s;

		return img.src.split("?separator=").pop();
	};

	/* 对URL的参数进行GBK或UTF-8编码 */
	this.encodeURL = function(s)
	{
		return encodeURIComponent(s);

		/* 把 多字节字符 与 单字节字符 分开，分别使用 escapeDBC 和 encodeURIComponent 进行编码 */
		/*return s.replace(/([^\x00-\xff]+)|([\x00-\xff]+)/g, function($0, $1, $2) {
			return escapeDBC($1) + encodeURIComponent($2 || '');
		});*/
	};

	this.doNothing = function()
	{
		return true;
	};

	/* 转换特殊的HTML标记 */
	this.htmlEscape = function(str)
	{
		var escapseStr = str;

		if (undefined != escapseStr)
		{
			escapseStr = escapseStr.toString().replace(/[<>&"]/g, function(match){
				switch(match)
				{
				case "<":
					return "&lt;";
				case ">":
					return "&gt;";
				case "&":
					return "&amp;";
				case "\"":
					return "&quot;";
				}
			});
		}

		return escapseStr;
	};

	/* 模拟鼠标点击操作 */
	this.simulateMouseC = function (target)
	{
		if (true == isIE && false == isIENormal)
		{
			simulateMouseC = function(target){
				var event = document.createEventObject();

				event.sceenX = 100;
				event.sceenY = 0;
				event.clientX = 0;
				event.clientY = 0;
				event.ctrlKey = false;
				event.altKey = false;
				event.shiftKey = false;
				event.button = 0;

				target.fireEvent("onclick", event);
			};
		}
		else
		{
			simulateMouseC = function(){};
		}

		simulateMouseC(target);
	};
}
function Switch(switchId, state, callback)
{
	this.switchCon = id(switchId);
	this.switchBall = $("#" + switchId + " i.switchBall")[0];
	this.switchBg = $("#" + switchId + " i.switchBg")[0];
	this.callback = callback;
	this.state = state;
	this.rightPos;

	if (typeof Switch.prototype.switchInit != "function")
	{
		Switch.prototype.switchInit = function(){
			var objThis = this;
			var state = this.state;
			var switchBall = this.switchBall;
			var switchCon = this.switchCon;
			var switchBg = this.switchBg;

			if (switchCon == null || switchBall == null)
			{
				return;
			}

			this.rightPos = switchCon.offsetWidth - switchBall.offsetWidth;
			this.setState(state);
			this.callback&&this.callback(state);
			switchBall.onmousedown = this.draggableBind();
			switchBg.onclick = this.switchBgClick();
		};

		/* 设置状态 */
		Switch.prototype.setState = function(state){
			var switchCon = this.switchCon;
			var switchBall = this.switchBall;

			this.state = state;
			switchCon.value = state;
			switchBall.style.left = state*this.rightPos + "px";
			if (state == 1)
			{
				switchBall.style.background = "url(../images/basic.png) no-repeat scroll -359px -234px";
			}
			else
			{
				switchBall.style.background = "url(../images/basic.png) no-repeat scroll -334px -234px";
			}
			hsSwitchState(switchCon.id, state);
		};

		/* 状态修改 */
		Switch.prototype.switchChgState = function(state){
			state = 1 - state;
			this.setState(state);
			this.callback&&this.callback(state);
		};

		/* 点击的响应函数 */
		Switch.prototype.switchCHandle = function(){
			/* 1为on, 0 为off */
			var state = this.state;
			var switchBall = this.switchBall;
			var tag = (state == 1 ? -1 : 1);
			var left = parseInt(switchBall.style.left);
			var width = this.rightPos;
			var obj = this;

			/* on to off */
			if ((state == 1 && left <= 0) || (state == 0 && left >= width))
			{
				this.switchChgState(state);
				return;
			}

			switchBall.style.left = left + tag*width/8 + "px";
			window.setTimeout(function(){obj.switchCHandle()}, 20);
		};

		Switch.prototype.msMove = function(ta, currMousePos, distance)
		{
			var taWidth = ta.offsetWidth;
			var posX = currMousePos.x - distance.x;
			var maxX = this.switchCon.offsetWidth - taWidth;

			posX = posX > 0 ? posX:0;
			posX = posX > maxX ? maxX:posX;
			ta.style.left = posX + "px";
		};

		/* switchBg的点击处理函数 */
		Switch.prototype.switchBgClick = function(){
			var objThis = this;

			return function(event){
				event = event || window.event;
				var target = event.target || event.srcElement;

				if (objThis.switchBg == target)
				{
					objThis.switchCHandle();
				}
			};
		};

		Switch.prototype.draggableBind = function()
		{
			var thisObj = this;

			return function(event){
				event = event ? event : window.event;
				var currMousePos = getMousePos(event);
				var ta = event.target || event.srcElement;

				/* 记录鼠标按下瞬间鼠标与控件左上角的距离 */	
				var distance = {x:currMousePos.x - ta.offsetLeft};

				document.onmousemove = function(event)
				{
					event = event ? event : window.event;
					var currMousePos = getMousePos(event);

					clearSelection();
					thisObj.msMove(ta, currMousePos, distance);
				};

				document.onmouseup = function(event)
				{
					clearSelection();
					document.onmousemove = null;
					document.onmouseup = null;
					thisObj.switchCHandle();
				};

				stopProp(event);
			};
		};
	}

	this.switchInit();
}
function HighSet()
{
	/* 存储提交按钮的Id */
	this.hsLoadingObj = {
		subBtnId:"",
		isBasic:false,
		isWl:false,
		handleCor:"",
		handleLoad:"",
		subLoadingHeight:""
	};

	/* 用于设置页面顶部的链接等的状态 */
	this.hsStatSet = function(state, des, idStr)
	{
		var handleRelCon, image, info;

		if (undefined == idStr)
		{
			handleRelCon = $("div.handleRelCon")[0];
			image = $("div.handleRelCon i.state")[0];
			info = $("div.handleRelCon span.state")[0];
		}
		else
		{
			handleRelCon = $("#" + idStr)[0];
			image = $("#" + idStr + " i.state")[0];
			info = $("#" + idStr + " span.state")[0];
		}

		switch(state)
		{
		case "null":
			handleRelCon.style.visibility = "hidden";
			break;
		case "correct":
			image.style.background = "url(../images/wzd.png) no-repeat -159px -248px";
			info.style.color = "#a0d468";
			info.innerHTML = des;
			handleRelCon.style.visibility = "visible";
			break;
		case "error":
			image.style.background = "url(../images/wzd.png) no-repeat -200px -248px";
			info.style.color = "#d86a54";
			info.innerHTML = des;
			handleRelCon.style.visibility = "visible";
			break;
		case "link":
			image.style.background = "url(../images/wzd.png) no-repeat -179px -248px";
			info.style.color = "#ffc600";
			info.innerHTML = des;
			handleRelCon.style.visibility = "visible";
			break;
		default:
			break;
		}
	};

	/* 用于设置输入框中的图标的显示 */
	this.disInputTip = function(target, tag)
	{
		if (target == null || tag == undefined)
		{
			return;
		}

		if (tag.toLowerCase() == "error")
		{
			this.setStyle(target, {"visibility":"visible", "background":"url(../images/wzd.png) no-repeat -116px -243px"});
		}
		else if (tag.toLowerCase() == "ok")
		{
			this.setStyle(target, {"visibility":"visible", "background":"url(../images/wzd.png) no-repeat -95px -243px"});
		}
		else if (tag.toLowerCase() == "warn")
		{
			this.setStyle(target, {"visibility":"visible", "background":"url(../images/wzd.png) no-repeat -137px -243px"});
		}
		else
		{
			target.style.visibility = "hidden";
		}
	};

	/* 设置编辑时输入框的样式 */
	this.initHoverBd = function()
	{
		$("input.hoverBd").bind("focus", function(){
			this.parentNode.style.border = "1px solid #A0D468";
		}).bind("blur", function(){
			this.parentNode.style.border = "1px solid #FFFFFF";
		});
	};

	/* 修改输入框的“启用”和禁用状态 */
	this.disableInput = function(target, disable){
		var input = (typeof target == "object" ? target : id(target));

		input.disabled = disable ? true : false;
		input.style.color =  disable ? "#B2B2B2" : "#000000";
	};

	/* 修改输入框的“启用”和禁用状态 */
	this.disableBtn = function(target, disable){
		var input = (typeof target == "object" ? target : id(target));
		var className = input.className;

		if (input.disabled == disable)
		{
			return;
		}

		input.disabled = disable ? true : false;
		input.className = disable ? className.replace("subBtn", "subBtnDis") : className.replace("subBtnDis", "subBtn");
	};

	/* 设置 subBtnId 的值*/
	this.setLoadingId = function(idStr, isBasic, isWl){
		this.hsLoadingObj.subBtnId = idStr;
		this.hsLoadingObj.isBasic = (isBasic != undefined);
		this.hsLoadingObj.isWl = (isWl != undefined);
	};

	/* 控制subLoading的显示和不显示的状态切换 */
	this.hsLoading = function(state){
		var hsLoadingObj = this.hsLoadingObj;
		var isBasic = hsLoadingObj.isBasic;
		var isWl = hsLoadingObj.isWl;
		var subBtn = id(hsLoadingObj.subBtnId);
		var btnLeft, btnHeight, btnTop, btnWidth;
		var con, subLoading;
		var obj = this;

		if (subBtn == null)
		{
			return;
		}

		con = subBtn.parentNode;
		con.style.position = "relative";
		btnLeft = subBtn.offsetLeft;
		btnTop = subBtn.offsetTop;
		btnWidth = subBtn.offsetWidth;
		btnHeight = subBtn.offsetHeight;
		subLoading = $("#" + hsLoadingObj.subBtnId + " ~ i.hsSubLoading")[0];

		/* 如果subLoading控件没有加载过，则进行加载 */
		if (subLoading == undefined)
		{
			subLoading = el("i");
			subLoading.className = "hsSubLoading";
			con.appendChild(subLoading);
			hsLoadingObj.subLoadingHeight = parseInt(getNodeDefaultView(subLoading, "height"));
		}

		/* 通过判断state的值，设置subLoading控件的显示情况 */
		if (state)
		{
			window.clearTimeout(hsLoadingObj.handleLoad);
			window.clearTimeout(hsLoadingObj.handleCor);

			if (subLoading.style.display != "none")
			{
				subLoading.style.display = "none";
			}

			if (true == isBasic)
			{
				if (true == isWl)
				{
					subLoading.style.background = "url(../images/basicLoadingWl.gif)";
				}
				else
				{
					subLoading.style.background = "url(../images/basicLoadingWa.gif)";
				}
			}
			else
			{
				subLoading.style.background = "url(../images/saveLoading.gif)";
			}

			subLoading.style.left = btnLeft + btnWidth + 5 +"px";
			subLoading.style.top = btnTop + (btnHeight - hsLoadingObj.subLoadingHeight)/2 + "px";
			subLoading.style.display = "inline-block";
		}
		else
		{
			obj.hsLoadingObj.subBtnId = "";

			/* 如果保存失败，则直接退出。 */
			if (ENONE != $.result.errorno)
			{
				if (undefined != subLoading)
				{
					subLoading.style.display = "none";
				}

				return;
			}

			if (true == isBasic)
			{
				hsLoadingObj.handleLoad = $.setTimeout(function()
				{
					if (undefined != subLoading)
					{
						subLoading.style.display = "none";
					}
				}, 1000);
			}
			else
			{
				hsLoadingObj.handleLoad = $.setTimeout(function()
				{
					if (undefined != subLoading)
					{
						subLoading.style.background = "url(../images/wzd.png) no-repeat -95px -243px";
						obj.hsLoadingObj.handleCor = $.setTimeout(function()
						{
							if (undefined != subLoading)
							{
								subLoading.style.display = "none";
							}
						}, 2000);
					}
				}, 1000);
			}
		}
	};

	this.hsSwitchState = function(conId, state)
	{
		var hsBCSwitchState = $("#" + conId + " ~ span.hsSwitchState")[0];

		if (hsBCSwitchState == null)
		{
			return;
		}

		if (1 == state)
		{
			hsBCSwitchState.innerHTML = statusStr.opened;
			hsBCSwitchState.style.color = "#86B157";
		}
		else
		{
			hsBCSwitchState.innerHTML = statusStr.closed;
			hsBCSwitchState.style.color = "#FB6E52";
		}
	};
}
function Basic()
{
	/* 加载Basic的页面 */
	this.loadBasic = function(pageName, conId, callBack){
		this.basicAutoFit();
		loadPage(pageName, conId, callBack);
	};

	/* 设置Basic页面的高度和fontSize */
	this.basicAutoFit = function()
	{
		var screenHeight = screen.height;
		var clientHeight = document.documentElement.clientHeight;

		/* 根据分辨率设置页面高度 */
		if (clientHeight < 768)
		{
			document.body.style.height = "768px";
		}
		else if (clientHeight > 900)
		{
			document.body.style.height;
		}

		/* 根据分辨率设置页面字体大小 */
		if (screenHeight <= 768)
		{
			document.body.style.fontSize = "12px";
		}
		else if (screenHeight > 900)
		{
			document.body.style.fontSize = "12px";
		}
		else
		{
			document.body.style.fontSize = "12px";
		}
	};
}
function ShowTips()
{
	this.alertTimeHd;
	this.shAltObjOrId;

	/* 用于显示错误的提示信息 */
	this.showAlert = function(errStr, objOrId){
		var error = id("Error");
		var hsErr = id("hsErr");
		var img, span, input;
		var objThis = this;

		if (true == isIESix)
		{
			alert(errStr);
			return;
		}

		this.shAltObjOrId = objOrId;
		input = $("div.hsTip input.subBtn")[0];

		if (hsErr == null)
		{
			hsErr = document.createElement("div");
			hsErr.id = "hsErr";
			hsErr.className = "hsTip";
			img = document.createElement("img");
			img.className = "altIcon";
			img.src = "../images/alert.gif";
			hsErr.appendChild(img);
			span =  document.createElement("span");
			span.className = "detail";
			hsErr.appendChild(span);
			input = document.createElement("input");
			input.type = "button";
			input.className = "subBtn";
			input.value = btn.ok;
			input.onclick = function(){
				objThis.closeAlert(true);
			};
			hsErr.appendChild(input);
			error.appendChild(hsErr);
		}

		hsErr.childNodes[1].innerHTML = errStr;
		error.style.visibility = "visible";
		error.style.top = "90px";
		input.focus();
		this.alertTimeHd = $.setTimeout(function(){objThis.closeAlert()}, 30000);
	};

	/* 用于关闭错误的提示信息 */
	this.closeAlert = function(btnClick){
		var error = id("Error");
		var objOrId = this.shAltObjOrId;

		if (error == null)
		{
			return;
		}

		error.style.top = "-9999px";
		error.style.visibility = "hidden";
		clearTimeout(this.alertTimeHd);
		this.alertTimeHd = null;

		if (true == btnClick && undefined != objOrId && (typeof objOrId == "object" || 0 != objOrId.length))
		{
			try
			{
				if (typeof objOrId != "object")
				{
					objOrId = id(objOrId);
				}

				$.setTimeout(function(){
					objOrId.select();
				}, 200);
			}catch(ex){};
		}
		else
		{
			this.shAltObjOrId = "";
		}
	};

	this.shAltBaObjOrId;

	/* 用于显示错误的提示信息 */
	this.showAlertB = function(errStr, objOrId){
		showCover(function (cover){
			var i, input, p, span, divCon, div;

			this.shAltBaObjOrId = objOrId;

			divCon = document.createElement("div");
			divCon.className = "baConfirmCon";
			document.body.appendChild(divCon);

			div = document.createElement("div");
			div.className = "baConfirm";
			divCon.appendChild(div);

			i = document.createElement("i");
			i.className = "baConfirmLogo";
			div.appendChild(i);

			span = document.createElement("span");
			span.className = "baConfirmQuestion";
			span.innerHTML = errStr;
			div.appendChild(span);

			input = document.createElement("input");
			input.className = "subBtn";
			input.value = btn.confirm;
			input.type = "button";
			input.onclick = function(){
				closeAlertB(true);
			};

			div.appendChild(input);
		});
	};

	this.closeAlertB = function(btnClick){
		var objOrId = this.shAltBaObjOrId;

		hideCover(function(){
			var divCon = $("div.baConfirmCon")[0];

			document.body.removeChild(divCon);

			if (true == btnClick && undefined != objOrId && (typeof objOrId == "object" || 0 != objOrId.length))
			{
				try
				{
					if (typeof objOrId != "object")
					{
						objOrId = id(objOrId);
					}

					objOrId.focus();
					objOrId.select();
				}catch(ex){};
			}
		});
	};

	/* 用于显示“确认信息” */
	this.showConfirm = function(confStr, callBack){
		var conf = id("Confirm");
		var hsConf = id("hsConf");
		var img, span, input, inputCol;
		var objThis = this;
		var result;

		if (true == isIESix)
		{
			result = confirm(confStr);
			this.closeConfirm();
			callBack(result);
			return;
		}

		if (hsConf == null)
		{
			hsConf = document.createElement("div");
			hsConf.id = "hsConf";
			hsConf.className = "hsTip";
			img = document.createElement("img");
			img.className = "altIcon";
			img.src = "../images/alert.gif";
			hsConf.appendChild(img);
			span =  document.createElement("span");
			span.className = "detail";
			hsConf.appendChild(span);
			input = document.createElement("input");
			input.type = "button";
			input.className = "subBtn";
			input.value = btn.cancel;
			hsConf.appendChild(input);
			input = document.createElement("input");
			input.type = "button";
			input.className = "subBtn";
			input.value = btn.ok;
			hsConf.appendChild(input);
			conf.appendChild(hsConf);
		}

		inputCol = $("#hsConf input");
		inputCol[0].onclick = function(){
			objThis.closeConfirm();
			callBack(false);
		};

		inputCol[1].onclick = function(){
			objThis.closeConfirm();
			callBack(true);
		};

		hsConf.childNodes[1].innerHTML = confStr;
		conf.style.visibility = "visible";
		conf.style.top = "90px";
	};

	/* 用于关闭“确认信息” */
	this.closeConfirm = function(){
		var conf = id("Confirm");

		if (conf == null)
		{
			return;
		}

		conf.style.top = "-9999px";
		conf.style.visibility = "hidden";
	};

	/* 用于显示提示信息 */
	this.showNote = function(idStr, noteStr){
		var noteCon = id(idStr);

		if (undefined == noteCon)
		{
			return;
		}

		if (undefined != noteStr)
		{
			$("#" + idStr + " div.noteCon p")[0].innerHTML = noteStr;
		}

		noteCon.style.visibility = "visible";
	};

	/* 用于关闭提示信息 */
	this.closeNote = function(idStr){
		var noteCon = id(idStr);

		if (undefined != noteCon)
		{
			noteCon.style.visibility = "hidden";
		}
	};

	/* 显示正在loading的状态 */
	this.showLoading = function(noteStr, closeCallBack, classObj)
	{
		closeLoading();
		showCover(function(cover){
			var coverId = cover.id;
			var loadCon, load, loadCover;
			var loadImg, detail, close;
			var cover$ = $("#" + coverId);
			var loadConClass, loadClass;
			var coverLoadingClass, detailClass;
			var coverOpacity = 0;

			if (undefined != classObj)
			{
				loadConClass = classObj.loadConClass;
				loadClass = classObj.loadClass;
				coverLoadingClass = classObj.coverLoadingClass;
				detailClass = classObj.detailClass;
				coverOpacity = classObj.coverOpacity || 0;
			}

			/* 将cover设置为透明的 */
			cover$.css("opacity", coverOpacity);

			loadCover = el("div");
			loadCover.className = "LoadConCover";
			document.body.appendChild(loadCover);

			loadCon = el("div");
			loadCon.className = loadConClass || "coverLoadCon";
			loadCover.appendChild(loadCon);

			load = el("div");
			load.className = loadClass || "coverLoad";
			loadCon.appendChild(load);

			close = el("i");
			close.className = "coverLoadClose";
			close.onclick = function(){
				closeLoading(closeCallBack);
			};
			load.appendChild(close);

			if (undefined == coverLoadingClass)
			{
				loadImg = el("img");
				loadImg.className = "coverLoading";
				loadImg.src = "../images/coverLoading.gif";
				load.appendChild(loadImg);
			}
			else
			{
				loadImg = el("i");
				loadImg.className = coverLoadingClass;
				load.appendChild(loadImg);
			}

			detail = el("p");
			detail.className = detailClass || "coverLoadNote";
			detail.innerHTML = (noteStr == undefined ? label.checkingWait : noteStr);
			load.appendChild(detail);
		});
	};

	/* 关闭正在loading的状态 */
	this.closeLoading = function(closeCallBack)
	{
		var loadCover = $("div.LoadConCover")[0];

		if (null == loadCover)
		{
			return;
		}

		$("#" + this.CoverId).css("opacity", "");
		document.body.removeChild(loadCover);
		hideCover(closeCallBack);
	};

	/* 调试输出 */
	this.debugInfo = function()
	{
		var info = "";

		for (var i = 0, len = arguments.length; i < len; i++)
		{
			info += (arguments[i] + "\r\n");
		}

		alert(info);
	}
}
function Select()
{
	this.selectInit = function(idStr, options, value, callback, maxSize)
	{
		var li, tmp, parent, valueCon, visible = "hidden";
		var ul = document.createElement("ul");
		var con = id(idStr), className = "selOptsUl";
		var colorN = "#FFFFFF", colorC = "#48b4ff";
		var fontColorN = "", fontColorC = "#FFFFFF";
		var valueColor = "#000000", valueDisColor = "#B2B2B2";
		var valueConTmp, showSize, valueConWidth, fontSize;
		var escapeStr, listScroll, valueDef = value;

		parent = con.parentNode;
		valueConTmp = $("#"+idStr+" span.value");
		fontColorN = valueConTmp.css("color");
		valueCon = valueConTmp[0];
		valueCon.value = 0;
		valueConWidth = parseInt(valueConTmp.css("width"));
		fontSize = (parseInt(valueConTmp.css("fontSize"))*0.61).toFixed(1);
		showSize = (maxSize == undefined ? parseInt(valueConWidth/fontSize) : maxSize);
		con.value = 0;
		ul.className = className;
		ul.id = className + idStr;
		parent.appendChild(ul);

		function hiddenSelect(ul)
		{
			var visibilityVal, li;
			var options = ul.childNodes;

			for (var i = 0, len = options.length; i < len; i++)
			{
				li = options[i];
				visibilityVal = li.childNodes[0].style.visibility;
				li.style.backgroundColor = (visibilityVal == "visible"?colorC:colorN);
				li.style.color = (visibilityVal == "visible"?fontColorC:fontColorN);
			}

			ul.style.visibility = "hidden";
			ul.style.top = "-9999px";
			ul.parentNode.style.position = "static";
		}

		attachEvnt(document.body, "click", function(){
			var ul = $("#"+className + idStr)[0];

			if (typeof ul == "undefined")
			{
				return;
			}

			hiddenSelect(ul);
		});

		function optionClick(li)
		{
			var con = id(idStr)
			var target = li;
			var parent = target.parentNode;
			var options = parent.childNodes;
			var valueCon = $("#"+idStr+" span.value")[0];

			if (target.childNodes[0].nodeType == 3)
			{
				return;
			}

			con.value = target.valueStr;
			valueCon.value = target.valueStr;

			for (var i = 0, len = options.length; i < len; i++)
			{
				options[i].childNodes[0].style.visibility = "hidden";
				options[i].style.backgroundColor = colorN;
				options[i].style.color = fontColorN;
			}

			if (target.childNodes[0].style.visibility != "visible" && 
				typeof callback != "undefined")
			{
				callback(target.valueStr, con);
			}

			target.childNodes[0].style.visibility = "visible";
			target.style.backgroundColor = colorC;
			target.style.color = fontColorC;
			valueCon.innerHTML = htmlEscape(target.childNodes[1].nodeValue);
			parent.style.visibility = "hidden";
			parent.style.top = "-9999px";
			parent.parentNode.style.position = "static";
		}

		function optionInit(options)
		{
			for (var i = 0, len = options.length; i < len; i++)
			{
				tmp = options[i];
				escapeStr = htmlEscape(getStrInMax(tmp.str.toString(), showSize));
				visible = "hidden";

				li = document.createElement("li");

				if ((tmp.value == undefined && i == valueDef) || (valueDef == tmp.value))
				{
					visible = "visible";
					valueCon.innerHTML = escapeStr;
					valueCon.value = valueDef;
					con.value = valueDef;
					li.style.backgroundColor = colorC;
					li.style.color = fontColorC;
				}

				li.innerHTML = "<span style='visibility:" + visible + "'>√</span>" + escapeStr;
				li.title = tmp.str;
				li.valueStr = (tmp.value != undefined ? tmp.value : i);
				li.className = "option";
				li.style.color = fontColorN;
				li.onclick = function(event)
				{
					event = event || window.event;
					optionClick(this);
					stopProp(event);
				};

				li.onmousemove = function(event){
					event = event || window.event;
					var target = event.srcElement || event.target;
					var options;

					if (target.tagName.toLowerCase() == "span")
					{
						return;
					}

					options = target.parentNode.childNodes;

					for (var i = 0, len = options.length; i < len; i++)
					{
						options[i].style.backgroundColor = colorN;
						options[i].style.color = fontColorN;
					}

					target.style.backgroundColor = colorC;
					target.style.color = fontColorC;
				};

				ul.appendChild(li);
			}
		}

		function selectClick(event)
		{
			var target = $("#"+ className + idStr);
			var sel = $("ul."+ className);

			/* 先隐藏其他下拉列表 */
			sel.each(function(){
				if (this.style.visibility == "visible")
				{
					hiddenSelect(this);
				}
				return true;
			});

			target.css("visibility", "visible").css("top", "-1px");
			target[0].parentNode.style.position = "relative";
			stopProp(event);
		}

		optionInit(options);

		con.onclick = selectClick;
		con.disable = function(value){
			con.onclick = (value == true ? null : selectClick);
			valueCon.style.color = (value == true ? valueDisColor : valueColor);
		};
		con.changeSel = function(value){
			var selOptions = $("#"+ className + idStr+" li");

			$("#"+ className + idStr+" li").each(function(){
				if (this.valueStr == value)
				{
					optionClick(this);
					return false;
				}
			});
		};
		con.resetOptions = function(options, value){
			ul.innerHTML = "";
			valueDef = value || 0;
			optionInit(options);
		};

		listScroll = new NiceScroll(ul.id);
		listScroll.scrollTipOpacity(1);
		listScroll.scrollTipSet({background:"#999999"});
		listScroll.init();
	};
}
function Help()
{
	var objThis = this;

	this.help = "Help";
	this.helpDetail = "helpDetail";
	this.helpContent = "helpContent";
	this.helpInit = function()
	{
		var hp = id(this.help);
		var p, span, i, div;
		var objThis = this;

		if (hp.innerHTML.length != 0)
		{
			loadPage("Help.htm", this.helpContent);
			return;
		}

		p = document.createElement("p");
		p.className = "helpTop";
		p.onmousedown = this.draggableBind(this.help);
		hp.appendChild(p);
		span = document.createElement("span");
		span.className = "helpDes";
		span.innerHTML = label.help;
		p.appendChild(span);
		i = document.createElement("i");
		i.onclick = function (){
			objThis.helpClose();
		};
		i.className = "helpClose";
		p.appendChild(i);
		div = document.createElement("div");
		div.id = "helpDetail";
		hp.appendChild(div);

		div = document.createElement("div");
		div.style.display = "none";
		div.id = this.helpContent;
		document.body.appendChild(div);
		loadPage("Help.htm", this.helpContent);

		/* 触屏移动开始的处理函数 */
		attachEvnt(p, "touchstart", function(event){
			event = event || window.event;
			objThis.mousePos = {x:event.touches[0].clientX, y:event.touches[0].clientY};
			attachEvnt(document, "touchmove", touchMoveHd);
			attachEvnt(document, "touchend", touchEndHd);
		});
	};
	/* 触屏移动的处理函数 */
	this.touchMoveHd = function(event)
	{
		event = event || window.event;
		var mousePos = {x:event.touches[0].clientX, y:event.touches[0].clientY};
		var hp = id(objThis.help);
		var divWidth = hp.offsetWidth;
		var divHeight = hp.offsetHeight;
		var posX = mousePos.x - objThis.mousePos.x;
		var posY = mousePos.y - objThis.mousePos.y;
		var maxX = document.body.clientWidth - divWidth;
		var maxY = document.documentElement.scrollHeight - divHeight;

		posX = posX > 0 ? posX:0;
		posY = posY > 0 ? posY:0;
		posX = posX > maxX ? maxX:posX;
		posY = posY > maxY ? maxY:posY;
		hp.style.left = posX + "px";
		hp.style.top = posY + "px";
		eventPreventDefault(event);
		clearSelection(event);
	};
	/* 触屏结束移动的处理函数 */
	this.touchEndHd = function(event)
	{
		detachEvnt(document, "touchmove", touchMoveHd);
		detachEvnt(document, "touchend", touchEndHd);
	};
	this.helpBind = function(btn, helpIdStr)
	{
		btn&&(btn.onclick = function(event){
			event = event || window.event;
			var target = event.target || event.srcElement;

			helpShow(helpIdStr, target);
		});
	};
	this.helpClose = function()
	{
		var hp = id(this.help);
		var hpDe = id(this.helpDetail);

		if (hpDe == null || hp == null)
		{
			return;
		}

		setStyle(hp, {"visibility":"hidden", "top":"-9999px"});
		hpDe.innerHTML = "";
	};
	this.helpVisible = function(btn)
	{
		var hp = id(this.help);
		var pos = $(btn).offset();
		var width = hp.offsetWidth;
		var height = hp.offsetHeight;
		var helpBtnHeight = btn.offsetHeight;
		var helpBtnWidth = btn.offsetWidth;
		var beBasic = btn.getAttribute("basicHelpTag");
		var top, left;

		/* 常用设置help */
		if (beBasic != null)
		{
			top = pos.top + helpBtnHeight*0.1 - height*2 + "px";
			left = pos.left + helpBtnWidth + 100 + "px";
		}
		else
		{
			top = pos.top + helpBtnHeight*0.1 + "px";
			left = pos.left - width + helpBtnWidth/1.5 + "px";
		}

		setStyle(hp, {"visibility":"visible", "top":top, "left":left});
	};
	this.helpDetailAppend = function(helpIdStr)
	{
		var hpDe;
		var helpCon = id(helpIdStr);

		if (null == helpCon)
		{
			return;
		}

		hpDe = id(this.helpDetail);
		hpDe.innerHTML = helpCon.outerHTML;
	};
	this.helpShow = function(helpIdStr, btn)
	{
		this.helpClose();
		this.helpVisible(btn);
		helpDetailAppend(helpIdStr);
	};
	this.msMove = function(helpDiv, currMousePos, distance)
	{
		var divWidth = helpDiv.offsetWidth;
		var divHeight = helpDiv.offsetHeight;
		var posX = currMousePos.x - distance.x;
		var posY = currMousePos.y - distance.y;
		var maxX = document.body.clientWidth - divWidth;
		var maxY = document.documentElement.scrollHeight - divHeight;

		posX = posX > 0 ? posX:0;
		posY = posY > 0 ? posY:0;
		posX = posX > maxX ? maxX:posX;
		posY = posY > maxY ? maxY:posY;
		helpDiv.style.left = posX + "px";
		helpDiv.style.top = posY + "px";
	};
	this.draggableBind = function(divPaId)
	{
		var inFrame = 1;
		var inSetFrame = 2;
		var outChild = 0;
		var helpDiv = id(divPaId);

		return function(event){
			event = event ? event : window.event;
			var currMousePos = getMousePos(event);

			/* 记录鼠标按下瞬间鼠标与DIV控件左上角的距离 */	
			var distance = {x:currMousePos.x - helpDiv.offsetLeft,
							y:currMousePos.y - helpDiv.offsetTop};

			document.onmousemove = function(event)
			{
				event = event ? event : window.event;
				var currMousePos = getMousePos(event);

				clearSelection();
				msMove(helpDiv, currMousePos, distance);
			};

			document.onmouseup = function()
			{
				clearSelection();
				document.onmousemove = null;
				document.onmouseup = null;
			};
		};
	};
}
function ProgressBar()
{
	this.progresshd;
	this.progressBar;
	this.pregressDeWidth;

	this.initProgBar = function()
	{
		var rebootCon = id("ProgressBar");
		var con, div, p;

		if (null == rebootCon)
		{
			rebootCon = document.createElement("div");
			rebootCon.id = "ProgressBar";
			document.body.appendChild(rebootCon);

			con = document.createElement("div");
			con.className = "progressBarCon";
			rebootCon.appendChild(con);

			p = document.createElement("p");
			p.className = "progressBarDes";
			con.appendChild(p);

			div = document.createElement("div");
			div.className = "progressBarBg";
			con.appendChild(div);

			p = document.createElement("p");
			p.className = "progressBarDe";
			div.appendChild(p);

			this.progressBar = rebootCon;
			this.pregressDeWidth = parseInt($("p.progressBarDe").css("width"));
		}
	};

	this.progRunning = function(showPercent, duration, callBack){
		var progressBarBg = $("div.progressBarBg");
		var progressBarDe = $("p.progressBarDe");
		var deWidth = this.pregressDeWidth;
		var width = parseInt(progressBarBg.css("width")) - deWidth -
					parseInt(progressBarDe.css("paddingRight"));
		var time = duration/100, count = 0;
		var obj = this;

		function proRun()
		{
			if (count > 100)
			{
				if (undefined != callBack)
				{
					callBack();
				}

				return;
			}

			if (showPercent == true)
			{
				progressBarDe[0].innerHTML = count + "%";
			}

			progressBarDe.css("width", deWidth + width*count + "px");
			count++;
			obj.progresshd = $.setTimeout(arguments.callee, time);
		}

		progressBarDe.css("width", deWidth + "px");
		width = parseFloat(width/100);
		proRun();
	};

	this.showProgBar = function(duration, noteStr, callBack, showPercent)
	{
		this.initProgBar();

		setStyle(this.progressBar, {"display":"block", "visibility":"visible", "top":"0px"});

		if (undefined == noteStr)
		{
			noteStr = statusStr.rebooting;
		}

		$("p.progressBarDes")[0].innerHTML = noteStr;

		this.progRunning((showPercent == undefined?true:showPercent), duration, callBack);
	};

	this.closeProgBar = function()
	{
		clearTimeout(this.progresshd);
		setStyle(this.progressBar, {"display":"none", "visibility":"hidden", "top":"-9999px"});
	};
}
(function(){
	Tool.call(window);
	PageFunc.call(window);
	Cover.call(window);
	Explorer.call(window);
	LocalStorageSD.call(window);
	HighSet.call(window);
	Basic.call(window);
	ShowTips.call(window);
	Select.call(window);
	ProgressBar.call(window);
	Help.call(window);
})();